package cn.tedu.charging.user.controller;


import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.pojo.param.WxLoginParam;
import cn.tedu.charging.common.pojo.vo.BalanceVO;
import cn.tedu.charging.common.pojo.vo.UserDetailVO;
import cn.tedu.charging.common.pojo.vo.WxLoginVO;
import cn.tedu.charging.user.pojo.param.LoginParam;

import cn.tedu.charging.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;
    @GetMapping("/detail/{id}")
    public JsonResult detail(@PathVariable("id") Integer id) {
        log.debug("控制层-Controller 用户详情,入参:{}", id);
        UserDetailVO userDetailVO = userService.detail(id);
        JsonResult jsonResult  = JsonResult.ok(userDetailVO);
        log.debug("控制层-Controller 用户详情,入参:{},出参:{}", id, jsonResult );
        return jsonResult ;
    }
    @PostMapping("/wx/login")
    public JsonResult<WxLoginVO> wxLogin(@RequestBody WxLoginParam param){
        //业务实现暂未完成
        WxLoginVO vo=userService.wxLogin(param);
        return JsonResult.ok(vo);
    }
    //查询用户余额,这个接口业务我们轻做
    @GetMapping("/balance/{userId}")
    public JsonResult<BalanceVO> balance(@PathVariable("userId") Integer userId){
        //业务就轻做,不实现,直接返回一个5000的余额的值
        BalanceVO vo=new BalanceVO();
        vo.setBalance(5000D);
        return JsonResult.ok(vo);
    }
}